package com.yshy.moviechoseseatinginnerapi.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.yshy.moviechoseseatinginnerapi.service.FilmsService;
import com.yshy.moviechoseseatingcommon.entity.bo.films.*;
import com.yshy.moviechoseseatingcommon.entity.vo.films.*;
import com.yshy.moviechoseseatingcommon.util.RequstUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author :
 * @desc :
 * @create: 下午6:58
 **/
@Service
public class FilmsServiceImpl implements FilmsService {
    @Autowired
    private RequstUtil requstUtil;

    @Override
    public String listAll() {
        ListAllVo listAllVo = requstUtil.filmsListAll();
        if(listAllVo==null){
            return "请求异常";
        }
        return JSONObject.toJSONString(listAllVo, SerializerFeature.WriteMapNullValue);
    }

    @Override
    public String listByCityId(ListByCityIdsBo bo) {
        if(bo.getCityId()==null&&bo.getCityCode()==null){
            return "参数异常,城市Id，和城市编号二选一";
        }
        if(bo.getCityId()!=null&&bo.getCityCode()!=null){
            return "参数异常,城市Id，和城市编号二选一";
        }
        ListByCityIdsVo listByCityIdsVo = requstUtil.filmsListByCityId(bo);
        if(listByCityIdsVo==null){
            return "请求异常";
        }
        return JSONObject.toJSONString(listByCityIdsVo,SerializerFeature.WriteMapNullValue);
    }

    @Override
    public String listByCinemaId(ListByCinemaIdsBo bo) {
        ListsByCinemaIdVo listsByCinemaIdVo = requstUtil.filmsListByCinemaId(bo);
        if(listsByCinemaIdVo==null){
            return "请求异常";
        }
        return JSONObject.toJSONString(listsByCinemaIdVo,SerializerFeature.WriteMapNullValue);
    }

    @Override
    public String pagedQuery(PagedQuerysBo bo) {
        if(bo.getCityId()==null&&bo.getCityCode()==null&&bo.getCinemaId()==null){
            return "参数异常,城市Id，和城市编号，和影院id三选一";
        }
        if(bo.getCityId()!=null&&bo.getCityCode()!=null&&bo.getCinemaId()!=null){
            return "参数异常,城市Id，和城市编号，和影院id三选一";
        }
        PagedQuerysVo pagedQuerysVo = requstUtil.filmsPagedQuery(bo);
        if(pagedQuerysVo==null){
            return "请求异常";
        }
        return JSONObject.toJSONString(pagedQuerysVo,SerializerFeature.WriteMapNullValue);
    }

    @Override
    public String pagedQueryNotShownFilms(PagedQueryNotShownFilmsBo bo) {
        PagedQueryNotSHownFilmsVo pagedQueryNotSHownFilmsVo = requstUtil.filmsPagedQueryNotShownFilms(bo);
        if(pagedQueryNotSHownFilmsVo==null){
            return "请求异常";
        }
        return JSONObject.toJSONString(pagedQueryNotSHownFilmsVo,SerializerFeature.WriteMapNullValue);
    }

    @Override
    public String getById(GetByIdsBo bo) {
        GetByIdsVo getByIdsVo = requstUtil.filmsGetById(bo);
        if(getByIdsVo==null){
            return "请求异常";
        }
        return JSONObject.toJSONString(getByIdsVo,SerializerFeature.WriteMapNullValue);
    }
}
